package com.xuelang.pipeline.entry.resource;

import com.xuelang.pipeline.app.resource.CloudEnvironmentService;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.resource.ICloudEnvironmentService;
import com.xuelang.pipeline.client.resource.dto.CloudEnvironmentDTO;
import com.xuelang.pipeline.client.resource.dto.CloudEnvironmentQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 多云环境服务web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/cloud-environment")
public class CloudEnvironmentController implements ICloudEnvironmentService {

    @Autowired
    private CloudEnvironmentService cloudEnvironmentService;

    @Override
    public ApiResult<PageRecord<CloudEnvironmentDTO>> pageCloudEnvironmentList(PageParam<CloudEnvironmentQuery> dtoPageParam) {
        return ApiResult.success(cloudEnvironmentService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<CloudEnvironmentDTO>> conditionalCloudEnvironmentList(CloudEnvironmentQuery cloudEnvironmentQuery) {
        return ApiResult.success(cloudEnvironmentService.list(cloudEnvironmentQuery));
    }


    @Override
    public ApiResult<Boolean> addCloudEnvironment(CloudEnvironmentDTO cloudEnvironmentDTO) {
        return ApiResult.success(cloudEnvironmentService.add(cloudEnvironmentDTO));
    }

    @Override
    public ApiResult<Boolean> updateCloudEnvironment(CloudEnvironmentDTO cloudEnvironmentDTO) {
        return ApiResult.success(cloudEnvironmentService.update(cloudEnvironmentDTO));
    }

    @Override
    public ApiResult<Boolean> deleteCloudEnvironment(Long id) {
        return ApiResult.success(cloudEnvironmentService.delete(id));
    }

    @Override
    public ApiResult<CloudEnvironmentDTO> queryCloudEnvironment(Long id) {
        return ApiResult.success(cloudEnvironmentService.query(id));
    }
}